/*****************************************************************//**
 * \file   AnsysAPDLReader_Mat.h
 * \brief  AnsysAPDLReader_Mat
 *
 * \author Niuyu
 * \date   June 8, 2023
 *********************************************************************/
#pragma once
#include "AnsysAPDLReaderBase.h"
#include "AnsysDataDef.h"

enum AnsysSelAction
{
	UNKNOWN,
	S,
	R,
	A,
	U,
	ALL,
	NONE,
	INVE,
	STAT,
};
enum AnsysSelItem
{
	UNKNOWNITEM,
	TYPE,
	REAL,
	ELEM,
	ADJ,
	CENT,
	ENAME,
	MAT,
	ESYS,
	OVER,
	LIVE,
	LAYER,
	SEC,
	STRA,
	SFE,
	BFE,
	PATH,
	ETAB
};
struct AnsysSelect
{
	ANSYS_TARGET_TYPE selType;
	AnsysSelAction actionType;
	AnsysSelItem item;
	std::string componentName;

	std::vector<int> selectData;
	std::vector<int> dataIndex;   //! used only nodes selected from element

	void clear()
	{
		selType = ANSYS_TARGET_TYPE::TARGET_UNKNOWN;
		actionType = (AnsysSelAction)0;
		item = (AnsysSelItem)0;
		componentName = "";
		selectData.clear();
		dataIndex.clear();
	}
};

class AnsysAPDLReader_NSEL : public ReaderBase
{
	DECLARE_CDB_READER(AnsysAPDLReader_NSEL)
public:
	AnsysAPDLReader_NSEL(CDBReader* pCDBReader) : ReaderBase(pCDBReader) {}
	virtual ~AnsysAPDLReader_NSEL(void) {}

public:
	AnsysSelect _nodeSelected;

public:
	bool Read(std::string& strDataLine);

};

class AnsysAPDLReader_NSLE : public ReaderBase
{
	DECLARE_CDB_READER(AnsysAPDLReader_NSLE)
public:
	AnsysAPDLReader_NSLE(CDBReader* pCDBReader) : ReaderBase(pCDBReader) {}
	virtual ~AnsysAPDLReader_NSLE(void) {}

public:
	bool Read(std::string& strDataLine);

};

class AnsysAPDLReader_ESEL : public ReaderBase
{
	DECLARE_CDB_READER(AnsysAPDLReader_ESEL)
public:
	AnsysAPDLReader_ESEL(CDBReader* pCDBReader) : ReaderBase(pCDBReader) {}
	virtual ~AnsysAPDLReader_ESEL(void) {}

public:
	AnsysSelect _elementSelected;

public:
	bool Read(std::string& strDataLine);

};

class AnsysAPDLReader_CMSEL :public ReaderBase
{
	DECLARE_CDB_READER(AnsysAPDLReader_CMSEL)
public:
	AnsysAPDLReader_CMSEL(CDBReader* pCDBReader) : ReaderBase(pCDBReader) {};
	virtual~AnsysAPDLReader_CMSEL(void) {};

public:
	bool Read(std::string& strDataLine);
};

class AnsysAPDLReader_ALLSEL : public ReaderBase
{
	DECLARE_CDB_READER(AnsysAPDLReader_ALLSEL)
public:
	AnsysAPDLReader_ALLSEL(CDBReader* pCDBReader) : ReaderBase(pCDBReader) {}
	virtual ~AnsysAPDLReader_ALLSEL(void) {}

	enum class EntityOrder
	{
		ALL_ENTITY,
		VOLU_ENTITY,
		AREA_ENTITY,
		LINE_ENTITY,
		KP_ENTITY,
		ELEM_ENTITY,
		NODE_ENTITY,

		UNKNOWN_ENTITY
	};

	EntityOrder stringToEntityOrder(const std::string& str)
	{
		if (str == "ALL")
		{
			return EntityOrder::ALL_ENTITY;
		}
		else if (str == "VOLU")
		{
			return EntityOrder::VOLU_ENTITY;
		}
		else if (str == "VOLU")
		{
			return EntityOrder::AREA_ENTITY;
		}
		else if (str == "VOLU")
		{
			return EntityOrder::LINE_ENTITY;
		}
		else if (str == "VOLU")
		{
			return EntityOrder::KP_ENTITY;
		}
		else if (str == "VOLU")
		{
			return EntityOrder::ELEM_ENTITY;
		}
		else if (str == "VOLU")
		{
			return EntityOrder::NODE_ENTITY;
		}
		else
		{
			return EntityOrder::UNKNOWN_ENTITY;
		}
	};

public:
	bool Read(std::string& strDataLine);

};